﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL.TJDAL;
using Anke.SHManage.Utility;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class DriverReportHZPrintModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Data_Binding();

        }

        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.ToString("yyyy-MM-01");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
            Data_Binding();
        }

        private void Data_Binding()
        {
            E_StatisticsPermisson em = UserOperateContext.Current.getMaxPerForStatistics();
            string selfWorkCode = UserOperateContext.Current.Session_UsrInfo.WorkCode;          
            string selfCenterID = UserOperateContext.Current.Session_UsrInfo.P_Department.DispatchSubCenterID;         
            string selfStationID = UserOperateContext.Current.Session_UsrInfo.P_Department.DispatchSationID;
         
            string start = this.StartDate.Text.ToString();
            string end = this.EndDate.Text.ToString();
            string centerCode = this.Center.Text.ToString();
            string stationCode = this.Station.Text.ToString();
            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/DriverReportFZYZHZ.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", end);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed });
            TJDAL dal = new TJDAL();
            DataTable dt1 = dal.Get_TJ_DriverReportHZ(start, end, centerCode, stationCode,em, selfWorkCode, selfStationID, selfCenterID);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForD_DriverReportHZPrint", dt1));
            this.ReportViewer1.LocalReport.Refresh();
        }
    }
}